<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddColumnUsers20250923 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        //分类
        Schema::table('classify', function (Blueprint $table){
            $table->string('icon')->default('')->comment('icon');
            $table->string('description')->default('')->comment('描述');
        });

        //用户
        Schema::table('users', function (Blueprint $table){
            $table->integer('mobile_time')->index()->default(0)->comment('授权手机号时间');
            $table->integer('auth_type')->default(0)->comment('授权位置类型:0、书籍');
            $table->integer('auth_target_id')->default(0)->comment('根据类型匹配ID');
            $table->integer('expire_time')->nullable()->comment('会员到期时间');
        });

        //日报表
        Schema::table('daily_report', function (Blueprint $table){
            $table->integer('register_ct')->default(0)->comment('注册人数');
            $table->integer('mobile_ct')->default(0)->comment('手机号授权人数');
        });

        //章节单词
        Schema::table('book_word', function (Blueprint $table){
            $table->string('plot_remind')->default('')->comment('剧情提醒');
        });


        //订单
        Schema::create('orders', function (Blueprint $table){
            $table->increments('id');
            $table->string('order_code')->unique()->comment('订单ID')->default('');
            $table->integer('user_id')->comment('用户ID')->default(0);
            $table->integer('goods_type')->comment('商品类型')->default(0);
            $table->integer('goods_id')->comment('商品ID')->default(0);
            $table->string('title')->comment('商品标题')->default('');
            $table->string('desc')->comment('商品标题')->default('');
            $table->integer('price')->comment('价格')->default(0);
            $table->smallInteger('status')->comment('订单状态')->default(0);
            $table->integer('pay_type')->comment('支付类型 1、微信')->default(1);
            $table->string('prepay_id')->comment('预支付ID')->nullable();
            $table->text('logs')->comment('三方支付日志')->nullable();
            $table->string('thirty_order')->unique()->comment('三方支付订单号')->nullable();
            $table->integer('pay_time')->comment('支付时间')->default(0);
            $table->integer('refund_price')->comment('退款金额')->default(0);
            $table->string('out_refund_no')->unique()->comment('退款单号')->nullable();
            $table->text('refund_logs')->comment('退款日志')->nullable();

            $table->timestamps();
            $table->index(['user_id', 'status']);
        });

        //会员价格
        Schema::create('member_prices', function (Blueprint $table){
            $table->increments('id');
            $table->string('title')->comment('商品标题')->default('');
            $table->string('desc')->comment('商品标题')->default('');
            $table->integer('original_price')->comment('原价')->default(0);
            $table->integer('current_price')->comment('现价')->default(0);
            $table->integer('type')->unique()->comment('商品类型：0、1个月 1、3个月 2、半年 3、1年 4、3年')->default(0);
            $table->integer('sort')->comment('排序')->default(0);

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
